<?php

include_once($_SERVER['DOCUMENT_ROOT'] . '/htqlmba/configs/database.php');

class TinhTrang extends Database {

    private $TEN_TINH_TRANG_MAY;
    private $TEN_TINH_TRANG_MAY_OLD;

    public function setTEN_TINH_TRANG_MAY($TEN_TINH_TRANG_MAY) {
        $this->TEN_TINH_TRANG_MAY = $TEN_TINH_TRANG_MAY;
    }

    public function getTEN_TINH_TRANG_MAY() {
        return $this->TEN_TINH_TRANG_MAY;
    }

    public function setTEN_TINH_TRANG_MAY_OLD($TEN_TINH_TRANG_MAY_OLD) {
        $this->TEN_TINH_TRANG_MAY_OLD = $TEN_TINH_TRANG_MAY_OLD;
    }

    public function getTEN_TINH_TRANG_MAY_OLD() {
        return $this->TEN_TINH_TRANG_MAY_OLD;
    }

    // function them tram

    public function themTT() {
        $query = "insert into tinh_trang_may(TEN_TINH_TRANG_MAY) 
            values ('" . $this->getTEN_TINH_TRANG_MAY() . "')";
        $this->setQuery($query);
        return $this->executeQuery();
    }

    public function suaTT() {
        $query = "	UPDATE `mba`.`chi_tiet_tt_may` 
						SET `TEN_TINH_TRANG_MAY` = '" . $this->getTEN_TINH_TRANG_MAY() . "'
						WHERE `chi_tiet_tt_may`.`TEN_TINH_TRANG_MAY` = '" . $this->getTEN_TINH_TRANG_MAY_OLD() . "';";
        $this->setQuery($query);
        $this->executeQuery();


        $query = "	UPDATE `mba`.`tinh_trang_may` 
						SET `TEN_TINH_TRANG_MAY` = '" . $this->getTEN_TINH_TRANG_MAY() . "'
						WHERE `tinh_trang_may`.`TEN_TINH_TRANG_MAY` = '" . $this->getTEN_TINH_TRANG_MAY_OLD() . "';";
        $this->setQuery($query);
        return $this->executeQuery();
    }

    public function xoaTT() {
        $this->setQuery("delete from tinh_trang_may where  TEN_TINH_TRANG_MAY='" . $this->getTEN_TINH_TRANG_MAY() . "'");
        return $this->executeQuery();
    }

    public function dsTT() {
        $this->setQuery("select TEN_TINH_TRANG_MAY
							 from tinh_trang_may
ORDER BY `tinh_trang_may`.`TEN_TINH_TRANG_MAY` ASC
							 ");
        return $this->fetchAll();
    }

}

?>